<template>
  <el-form-item label="静态文本">
    <el-select v-model="optionModel.staticText" placeholder="Select" style="width: 240px">
      <el-option
        v-for="item in staticTextList"
        :key="item.id"
        :label="item.options.name"
        :value="item.options.name"
      >
      </el-option>
    </el-select>
  </el-form-item>
</template>

<script>
export default {
  name: 'StaticTextEditor',
  props: {
    designer: Object,
    selectedWidget: Object,
    optionModel: Object
  },
  data() {
    return {
      imageList: []
    }
  },
  computed: {
    staticTextList() {
      if (!this.designer || !this.designer.widgetList || this.designer.widgetList.length === 0) {
        return []
      }

      const findAllStaticTexts = (widgets) => {
        let results = []
        widgets.forEach((widget) => {
          // 如果是staticText组件，添加到结果中
          if (widget.type === 'staticText') {
            results.push(widget)
          }
          // 如果组件有widgetList属性(如module组件)，递归查找
          if (widget.widgetList && widget.widgetList.length > 0) {
            results = results.concat(findAllStaticTexts(widget.widgetList))
          }
        })
        return results
      }

      return findAllStaticTexts(this.designer.widgetList)
    }
  },
  mounted() {}
}
</script>

<style lang="scss"></style>
